package cn.yyh.org.controller;

import cn.yyh.basic.utils.R;
import cn.yyh.org.domain.Shop;
import cn.yyh.org.domain.VO.ShopVO;
import cn.yyh.org.service.IShopService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author 杨永航
 * @version 1.0
 * @Title: ShopController
 * @Package: cn.yyh.org.controller
 * @date 2021/6/29
 */
@RestController
@RequestMapping("/shop")
@Api(tags = "店铺管理相关操作")
public class ShopController {
    @Autowired
    private IShopService shopService;

    @GetMapping("listAll")
    public R listAll() {
        try {
            List<Shop> list = shopService.listAll();
            return R.oK().data("rows", list);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    @PostMapping("register")
    public R shopRegister(@RequestBody ShopVO shop) {
        try {
            shopService.save(shop);
            return R.oK();
        } catch (Exception e) {
            e.printStackTrace();
            return R.error().message(e.getMessage());
        }
    }

}
